package com.lsp.base.utils.imageloader;

import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.request.target.SimpleTarget;

/**
 * @author com.lsp.ibxs
 * @created 16/11/9 17:20
 */
public class WyImageLoader {

  private static WyImageLoader wyImageLoader;

  public static WyImageLoader getInstance() {
    if (null == wyImageLoader) {
      wyImageLoader = new WyImageLoader();
    }
    return wyImageLoader;
  }

  public void display(Context mContext, String url, ImageView imageView) {
    display(mContext, url, imageView, WyImageOptions.NONE);
  }

  public void display(Context mContext, String url, ImageView imageView, WyImageOptions options) {
    display(mContext, url, imageView, options, null);
  }

  public void display(Context mContext, String url, ImageView imageView, WyImageOptions options,
      Object transform) {
    display(mContext, url, imageView, options, transform, null);
  }

  public void display(Context mContext, String url, ImageView imageView, WyImageOptions options,
      Object transform, ImageLoaderListener imageLoaderListener) {
    new GlideBuilder().context(mContext)
        .imageUrl(url)
        .options(options)
        .transform(transform)
        .listen(imageLoaderListener)
        .display(imageView);
  }

  public void download(Context context, String imageUrl, SimpleTarget target) {
    download(context, imageUrl, target, WyImageOptions.NONE);
  }

  public void download(Context context, String imageUrl, SimpleTarget target,
      WyImageOptions options) {
    new GlideBuilder().context(context).imageUrl(imageUrl).options(options).download(target);
  }
}
